<?php
/*
  功能：题库 model
  作者：cxm
  时间：2019-10-23
*/

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;

class Question extends BaseModel {
    use SoftDeletes;
    protected $dates = ['deleted_at']; //开启deleted_at
    protected $table='question';  //绑定表

    /**
     * 选项
     */
    public function options(){
        return $this->hasMany(QuestionOptions::class,'question_id','id')->orderBy('sort','asc');
    }

    /**
     * 查询题答案
     * @param $questionIds 题ID
     * @return mixed
     */
    public static function getAnswer($questionIds){
        return self::whereIn('id',$questionIds)->pluck('answer','id')->toArray();
    }
}